<template>
  <div class="container">
    主页
    <br>
    <input type="text" v-model="num">
    <br>
    <button v-permission="'add'" @click="add" :disabled="btnMark('add')">加100</button>
    <button v-permission="'subtract'" @click="remove">减100</button>
    <p v-permission="'title'">this is title</p>
    <br>
    <hr>
    <br>
    <button @click="login('aaa')">超级管理员登陆</button>
    <button @click="login('bbb')">主管登陆</button>
    <button @click="login('ccc')">成员登陆</button>
  </div>
</template>

<script>
import axios from 'axios'

export default {
  name: 'HomeIndex',
  data () {
    return {
      num: 0
    }
  },
  computed: {
  },
  created () {
    // console.dir(this.$router.options.routes)
  },
  methods: {
    async login (type) {
      // root: true 从store根开始
      // this.$store.commit('setRoutes', [], { root: true })
      // 清除之前的路由和实例
      this.$store.commit('logout')

      const { data } = await axios.get(`${type}.json`)

      this.$store.commit('login', data.points)

      this.$store.dispatch('filterRoutes', data.data)
    },
    add () {
      this.num += 100
    },
    remove () {
      this.num -= 100
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
